package com.one.common.view.slidingtab;

import com.one.common.view.base.BaseFragment;
import com.one.common.view.pagestate.listpage.BaseListFragment;
import com.one.common.view.pagestate.statepage.BaseStateFragment;

import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

/**
 * Class Des:
 * Created by bjh on 2021/8/31.
 */
public class ScrollViewPagerAdapter extends FragmentPagerAdapter {

    private List<BaseFragment> mFragment;
    private String[] mTitle;

    public ScrollViewPagerAdapter(FragmentManager fm, List<BaseFragment> fragments, String[] mTitle) {
        super(fm);
        this.mFragment = fragments;
        this.mTitle = mTitle;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (mTitle != null || mTitle.length > 0)
            return mTitle[position];

        return super.getPageTitle(position);
    }

    @Override
    public BaseFragment getItem(int position) {
        return mFragment.get(position);
    }

    @Override
    public int getCount() {
        return mFragment != null ? mFragment.size() : 0;
    }


}